package com.intercept;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;

/**
 * Created by Administrator on 2017/3/18.
 * 管理员权限的拦截器
 */
public class AuthInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        ActionContext ac=ActionContext.getContext();
        Map<String,Object> session=ac.getSession();
        if(((int)session.get("privilege"))==9) {
            String result=actionInvocation.invoke();
            return result;
        }else{
            //不是管理员
            return "noadmin";
        }
    }
}
